package com.zhu.salesmanagement.utils;

import com.zhu.location.R;
import com.zhu.salesmanagement.common.Actions;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.provider.Settings;

/**
 * Dialog的一些实现
 * @author shane
 *
 */
public class DialogUtil {
	
	/**
	 * Create a simple dialog with title , content and button to close.
	 * 
	 * @param context 
	 * @param titleResId title resource id
	 * @param contentResId content resource id
	 * @param buttonResId button name resource id
	 * @return Dialog
	 * 
	 */
	public static Dialog getSimpleDialog(Context context , int titleResId , 
											int contentResId , int buttonResId){
		
	   return new AlertDialog.Builder(context)   
       .setTitle(titleResId).setMessage(contentResId)
       .setPositiveButton(buttonResId, new OnClickListener() { 
           public void onClick(DialogInterface a0, int a1) {   
             
           }   
       }).create();   
	}

	public static Dialog getSimpleDialog(Context context , String title , 
			String content ,OnClickListener l ){

		return new AlertDialog.Builder(context)   
			.setTitle(title).setMessage(content)
			.setPositiveButton(R.string.button_ok, l == null ? new OnClickListener() { 
			public void onClick(DialogInterface a0, int a1) {
		
			}} : l).create();   
	}

	public static void alertShowOprenGpsDetails(final Context context) {
		Actions.alertShowDetails(context, context.getString(R.string.tips_label), context.getString(R.string.gpsalert), 
				R.string.dialog_setting, R.string.dialog_close ,new android.content.DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int arg1) {
					Actions.openSettingIntent(context, Settings.ACTION_SECURITY_SETTINGS);
				}
			} , new android.content.DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int arg1) {
					
				}
			});
	}
}
